// 课程信息
export interface Course {
  id: string
  title: string
  thumb: string
  shortDesc: string
  description: string
  categoryId: string
  category?: CourseCategory
  isRequired: 0 | 1 // 0-选修 1-必修
  isShow: 0 | 1 // 0-隐藏 1-显示
  charge: number // 价格，单位：分
  duration: number // 课程时长，单位：秒
  studentsCount: number // 学员数量
  chaptersCount: number // 章节数量
  hoursCount: number // 课时数量
  attachmentsCount: number // 附件数量
  createdAt: string
  updatedAt: string
  publishedAt?: string
  chapters?: Chapter[]
  attachments?: CourseAttachment[]
  students?: CourseStudent[]
}

// 课程分类
export interface CourseCategory {
  id: string
  name: string
  parentId?: string
  sort: number
  isShow: 0 | 1
  children?: CourseCategory[]
  coursesCount: number
  createdAt: string
  updatedAt: string
}

// 课程章节
export interface Chapter {
  id: string
  courseId: string
  name: string
  sort: number
  duration: number // 章节时长，单位：秒
  hoursCount: number // 课时数量
  createdAt: string
  updatedAt: string
  hours?: Hour[]
}

// 课时
export interface Hour {
  id: string
  courseId: string
  chapterId: string
  title: string
  type: 'video' | 'audio' | 'image' | 'text' | 'document'
  duration: number // 课时时长，单位：秒
  sort: number
  isTryRead: 0 | 1 // 0-不可试看 1-可试看
  resourceId?: string
  resource?: Resource
  content?: string // 图文内容
  createdAt: string
  updatedAt: string
}

// 课程附件
export interface CourseAttachment {
  id: string
  courseId: string
  name: string
  type: string
  size: number
  url: string
  downloadCount: number
  createdAt: string
  updatedAt: string
}

// 课程学员
export interface CourseStudent {
  id: string
  courseId: string
  userId: string
  user?: Student
  progress: number // 学习进度，0-100
  isFinished: 0 | 1 // 0-未完成 1-已完成
  finishedAt?: string
  studyDuration: number // 学习时长，单位：秒
  createdAt: string
  updatedAt: string
}

// 学习记录
export interface StudyRecord {
  id: string
  userId: string
  courseId: string
  chapterId: string
  hourId: string
  totalDuration: number // 总时长
  finishedDuration: number // 已学时长
  progress: number // 进度百分比
  isFinished: 0 | 1
  finishedAt?: string
  createdAt: string
  updatedAt: string
}

// 资源信息
export interface Resource {
  id: string
  categoryId: string
  category?: ResourceCategory
  name: string
  extension: string
  size: number
  disk: string
  fileId: string
  path: string
  url: string
  createdAt: string
  updatedAt: string
}

// 资源分类
export interface ResourceCategory {
  id: string
  name: string
  parentId?: string
  sort: number
  children?: ResourceCategory[]
  resourcesCount: number
  createdAt: string
  updatedAt: string
}

// 课程搜索参数
export interface CourseSearchParams {
  page: number
  size: number
  keyword?: string
  categoryId?: string
  isRequired?: 0 | 1
  isShow?: 0 | 1
  startTime?: string
  endTime?: string
}

// 课程创建参数
export interface CreateCourseParams {
  title: string
  thumb: string
  shortDesc: string
  description: string
  categoryId: string
  isRequired?: 0 | 1
  isShow?: 0 | 1
  charge?: number
}

// 课程更新参数
export interface UpdateCourseParams {
  id: string
  title?: string
  thumb?: string
  shortDesc?: string
  description?: string
  categoryId?: string
  isRequired?: 0 | 1
  isShow?: 0 | 1
  charge?: number
}

// 章节创建参数
export interface CreateChapterParams {
  courseId: string
  name: string
  sort?: number
}

// 章节更新参数
export interface UpdateChapterParams {
  id: string
  name?: string
  sort?: number
}

// 课时创建参数
export interface CreateHourParams {
  courseId: string
  chapterId: string
  title: string
  type: 'video' | 'audio' | 'image' | 'text' | 'document'
  duration?: number
  sort?: number
  isTryRead?: 0 | 1
  resourceId?: string
  content?: string
}

// 课时更新参数
export interface UpdateHourParams {
  id: string
  title?: string
  type?: 'video' | 'audio' | 'image' | 'text' | 'document'
  duration?: number
  sort?: number
  isTryRead?: 0 | 1
  resourceId?: string
  content?: string
}

// 课程附件创建参数
export interface CreateCourseAttachmentParams {
  courseId: string
  name: string
  type: string
  size: number
  url: string
}

// 课程学员添加参数
export interface AddCourseStudentParams {
  courseId: string
  userIds: string[]
}

// 课程统计信息
export interface CourseStatistics {
  totalCourses: number
  publishedCourses: number
  totalStudents: number
  totalStudyDuration: number
  courseGrowth: Array<{
    date: string
    count: number
  }>
  categoryDistribution: Array<{
    categoryName: string
    count: number
  }>
  popularCourses: Array<{
    courseId: string
    courseTitle: string
    studentsCount: number
    studyDuration: number
  }>
  studyProgress: Array<{
    date: string
    duration: number
  }>
}